package demo4;

/**
 * @Author 12629
 * @Description：
 */
abstract class Animal {
    public String name;
    public int age;
    public Animal(String name,int age) {
        this.name = name;
        this.age = age;
    }
    public abstract void eat();
    //跑  游泳 .....
}
interface IRunning {
    void run();
}
interface IFlying {
    void fly();
}
interface ISwimming {
    void swim();
}
// 叫 跑  游泳
class Dog extends Animal implements IRunning,ISwimming {

    public Dog(String name,int age) {
        super(name,age);
    }

    @Override
    public void eat() {
        System.out.println(name +" 正在吃狗粮！");
    }

    @Override
    public void run() {
        System.out.println(name + " 正在四条腿跑！");
    }

    @Override
    public void swim() {
        System.out.println(name + " 正在四条腿狗刨！");
    }
}
//叫 跑 飞
class Bird extends Animal implements IRunning,IFlying {
    public Bird(String name,int age) {
        super(name,age);
    }
    @Override
    public void eat() {
        System.out.println(name +" 正在吃鸟粮！");
    }

    @Override
    public void run() {
        System.out.println(name+" 正在用两条细细的腿在跳着跑！");
    }

    @Override
    public void fly() {
        System.out.println(name +" 正在用两个翅膀飞！");
    }
}
class Duck extends Animal implements IFlying,IRunning,ISwimming {

    public Duck(String name, int age) {
        super(name, age);
    }

    @Override
    public void eat() {
        System.out.println(name +"正在吃鸭粮！");
    }

    @Override
    public void run() {
        System.out.println(name +"正在用大脚掌跑！");
    }

    @Override
    public void fly() {
        System.out.println(name +"正在用大翅膀飞！");
    }

    @Override
    public void swim() {
        System.out.println(name+"正在用大脚掌游泳！");
    }
}


class Robot implements IRunning{

    @Override
    public void run() {
        System.out.println("机器人在跑！");
    }
}
public class Test {

    public static void walk(IRunning iRunning) {
        iRunning.run();
    }

    public static void main(String[] args) {
        walk(new Robot());
    }

    public static void fly(IFlying iFlying) {
        iFlying.fly();
    }

    public static void swim(ISwimming iSwimming) {
        iSwimming.swim();
    }

    public static void main5(String[] args) {
        swim(new Dog("狗子",10));
        swim(new Duck("唐老鸭",3));
    }

    public static void main3(String[] args) {
        fly(new Bird("小鸟",3));
        fly(new Duck("唐老鸭",3));
    }



    public static void main2(String[] args) {
        walk(new Dog("狗子",10));
        walk(new Bird("小鸟",3));
        walk(new Duck("唐老鸭",3));
    }


    public static void func1(Animal animal) {
        animal.eat();
    }

    public static void main1(String[] args) {
        func1(new Dog("狗子",10));
        func1(new Bird("小鸟",3));
        func1(new Duck("唐老鸭",3));
    }
}
